<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta content="IE=8" http-equiv="X-UA-Compatible" />
    <title>{%add}</title>
    {$QPath}
    <link rel="stylesheet" type="text/css" href="__TMPL__../Admin/Public/base.css" />
    <script type="text/javascript" src="__TMPL__../Admin/Public/mootools.js"></script>
    <script type="text/javascript">
        var _validate=[
            ['name',[
                    { rule:'required',msg:'{%name_required}'}
                ]
            ]
        ];
    </script>
    <script type="text/javascript" src="__TMPL__../Admin/Public/base.js"></script>
</head>
<body>
   <div id="container">
       <table class="tabmenu" cellspacing="0">
           <tbody>
               <tr>
                   <td class="wedge">&nbsp;</td>
                   <td class="wmenu"><a href="__URL__/index">{%list}</a></td>
                   <td class="wmenu here" class="w80">{%add}</td>
                   <td>&nbsp;</td>
                </tr>
            </tbody>
        </table>
        <div class="main">
            <ul class="fnc">
                <li><button type="button" class="btn" onclick="doSave()">{%save}</button></li>
            </ul>
            <form id="ipsForm" method="post" action="__URL__">
                <input type="hidden" name="a" />
                <table class="ips">
                    <tbody>
                        <tr>
                            <th class="essential"><label for="parentCategorys" >{%parent}</label></th>
                            <td>
                                <select id="parentCategorys" name="pid"></select>
                                <script type="text/javascript">
                                    var optionPrefixCache={};
                                    var basePrefixStr="&nbsp;&nbsp;&nbsp;";
                                    optionPrefixCache["p0"]="";
                                    optionPrefixCache["p1"]=basePrefixStr;
                                    function getOptionPrefix(level){
                                        var key="p"+level;
                                        if( ! ( key in optionPrefixCache ) ){
                                            optionPrefixCache[key]=optionPrefixCache["p"+(parseInt(level)-1)]+basePrefixStr;
                                        }
                                        return optionPrefixCache[key];
                                    }
                                    var optionStr="";
                                    <iterate name="allCategorys" id="vo">
                                    optionStr+="<option value=\"{$vo['id']}\">"+getOptionPrefix({$vo['level']})+"{$vo['name']}</option>";
                                    </iterate>
                                    var pc=$('parentCategorys');
                                    pc.set('html',optionStr);
                                    <?php
                                    if(array_key_exists('catid',$_GET)){
                                        echo 'setSelectOption(pc,'.$_GET['catid'].')';
                                    }
                                    ?>
                                </script>
                            </td>
                        </tr>
                        <tr>
                            <th class="essential"><label for="pk2">{%name}</label></th>
                            <td>
                                <input id="pk2" type="text" name="name" maxlength="120" size="40" />
                                <p class="hint">{%name_length_limit}</p>
                            </td>
                        </tr>
                        <tr>
                            <th><label for="pk3">{%classify}</label></th>
                            <td>
                                <select id="pk3" name="classify" onchange="toggleJump(this)">
                                    <?php
                                    $postMeta=include CONFIG_PATH.'PostMeta.php';
                                    $categoryType=$postMeta['categorytype'];
                                    foreach($categoryType as $key=>$value){
                                    ?>
                                    <option value="{$key}">{$value}</option>
                                    <?php } ?>
                                    </iterate>
                                </select>
                                <script type="text/javascript">
                                    function toggleJump(obj){
                                        var tbody=$("jumpTbody");
                                        if(obj.options[obj.selectedIndex].value=="jump"){
                                            tbody.style.display=(Browser.Engine.trident)?"block":"table-row-group";
                                        }else{
                                            tbody.style.display="none";
                                        }
                                    }
                                </script>
                            </td>
                        </tr>
                    </tbody>
                    <tbody id="jumpTbody" style="display:none">
                        <tr>
                            <th class="essential"><label for="pk4">{%jump}</label></th>
                            <td>
                                <input id="pk4" type="text" name="jump" maxlength="255" size="54" />
                            </td>
                        </tr>
                    </tbody>
                    <tbody>
                        <tr>
                            <th><label for="pk5">{%keywords}</label></th>
                            <td>
                                <textarea id="pk5" name="keywords" rows="2" cols="60"></textarea>
                            </td>
                        </tr>
                        <tr>
                            <th><label for="pk6">{%describe}</label></th>
                            <td>
                                <textarea id="pk6" name="describe" rows="2" cols="60"></textarea>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </form>
            <ul class="fnc">
                <li><button type="button" class="btn" onclick="doSave()">{%save}</button></li>
            </ul>
        </div>
    </div>
    <script type="text/javascript">
        function doSave(){
            doAction('save',{
                    submitType:'ajax',
                    ajaxOptions:{
                        runningMsg:'{%running}',
                        successMsg:'{%createSuccess}<b>'+$("pk2").getProperty('value')+'</b>',
                        callback:function(result,json){
                            if(result=='success') window.location="__URL__/index";
                        }
                    }
                });
        }
    </script>
</body>
</html>
